package com.axxc.jpa.service.impl;

import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;

import com.axxc.jpa.entity.EnglishWordNoteBookEntity;
import com.axxc.jpa.out.filter.EnglishWordNoteBookFilter;
import com.axxc.jpa.out.model.EnglishWordNoteBook;
import com.axxc.jpa.repository.EnglishWordNoteBookRepository;
import com.axxc.jpa.service.AbstractCRUDService;
import com.axxc.jpa.service.IEnglishWordNoteBookService;
import com.axxc.jpa.specification.EnglishWordNoteBookSpec;

/**
 * @ClassName: EnglishWordNoteBookServiceImpl
 * @Description: TODO(这里用一句话描述这个类的作用)
 * @author xxc
 * @date 2018年8月20日 下午2:40:50
 * @see {@link https://gitee.com/biuabiu}
 */
@Service
public class EnglishWordNoteBookServiceImpl
		extends AbstractCRUDService<EnglishWordNoteBook, EnglishWordNoteBookEntity, EnglishWordNoteBookFilter, Long>
		implements IEnglishWordNoteBookService {

	@Autowired
	private EnglishWordNoteBookRepository englishWordNoteBookRepository;

	@Override
	protected EnglishWordNoteBookEntity toEntity(EnglishWordNoteBook model) {
		EnglishWordNoteBookEntity target = new EnglishWordNoteBookEntity();
		BeanUtils.copyProperties(model, target);
		return target;
	}

	@Override
	protected EnglishWordNoteBook toModel(EnglishWordNoteBookEntity entity) {
		EnglishWordNoteBook target = new EnglishWordNoteBook();
		BeanUtils.copyProperties(entity, target);
		return target;
	}

	@Override
	protected Specification<EnglishWordNoteBookEntity> toFilter(EnglishWordNoteBookFilter filter) {
		// TODO Auto-generated method stub
		return new EnglishWordNoteBookSpec(filter);
	}

	@Override
	public EnglishWordNoteBookEntity findByEnglishWord(String englishWord) {
		return this.englishWordNoteBookRepository.findByEnglishWord(englishWord);
	}

	@Override
	public EnglishWordNoteBookEntity save(EnglishWordNoteBookEntity e) {
		return this.englishWordNoteBookRepository.save(e);
	}

}
